package com.gujiangbo.multithreadskill;

/**
 * @author gujiangbo
 */
public class MyThread {
    public static void main(String[] args) {
        TestThread thread = new TestThread();
        thread.setName("testThread");
        thread.start();
        try {
            for (int i = 0; i < 100; i++) {
                int time = (int) (Math.random() * 1000);
                Thread.sleep(time);
                System.out.println("run=" + Thread.currentThread().getName());
            }
        } catch (Exception e) {
            e.getStackTrace();
        }

    }
}

class TestThread extends Thread {
    @Override
    public void run() {
        try {
            for (int i = 0; i < 100; i++) {
                int time = (int) (Math.random() * 1000);
                Thread.sleep(time);
                System.out.println("run=" + Thread.currentThread().getName());
            }
        } catch (Exception e) {
            e.getStackTrace();
        }
    }
}